﻿namespace SharePointPowerToys.PowerQueryWebPart.HelpersTests
{
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using SharePointPowerToys.PowerQueryWebPart.Helpers;
    
    /// <summary>
    ///This is a test class for HelpersTest and is intended
    ///to contain all HelpersTest Unit Tests
    ///</summary>
    [TestClass()]
    public class HelpersTest
    {


        private TestContext testContextInstance;
        private string xmlTest = "<test><value1>1</value1><value2>2</value2></test>";
        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for StringGet
        ///</summary>
        [TestMethod()]
        public void StringGetTest1()
        {
            string value = "test";
            string expected = "test";
            string actual;
            actual = Helpers.StringGet(value);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for StringGet
        ///</summary>
        [TestMethod()]
        public void StringGetTest()
        {
            string value = string.Empty;
            string defaultValue = "test";
            string expected = "test";
            string actual;
            actual = Helpers.StringGet(value, defaultValue);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for TagContentsRemove
        ///</summary>
        [TestMethod()]
        public void TagContentsRemoveTest()
        {
            string source = xmlTest;
            string tag = "value1";
            string expected = "<test><value2></value2></test>";
            string actual;
            actual = Helpers.TagContentsRemove(source, tag);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for TagGet
        ///</summary>
        [TestMethod()]
        public void TagGetTest2()
        {
            string source = xmlTest;
            string tag = string.Empty;
            string defaultValue = string.Empty;
            string expected = "1";
            string actual;
            actual = Helpers.TagGet(source, tag, defaultValue);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for TagGet
        ///</summary>
        [TestMethod()]
        public void TagGetTest1()
        {
            string source = xmlTest;
            string tag = "value1";
            string expected = "1";
            string actual;
            actual = Helpers.TagGet(source, tag);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for TagGet
        ///</summary>
        [TestMethod()]
        public void TagGetTest()
        {
            string source = xmlTest;
            string tag = "value1";
            string defaultValue = string.Empty;
            bool includeTag = false;
            string expected = "1";
            string actual;
            actual = Helpers.TagGet(source, tag, defaultValue, includeTag);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

        /// <summary>
        ///A test for TagGet
        ///</summary>
        [TestMethod()]
        public void TagGetIncludeTagTest()
        {
            string source = xmlTest;
            string tag = "value1";
            string defaultValue = string.Empty;
            bool includeTag = true;
            string expected = "<value1>1</value1>";
            string actual;
            actual = Helpers.TagGet(source, tag, defaultValue, includeTag);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }

    }
}
